package chapter01_Arr

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test09_Tuple
 * Package: chapter01_Arr
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-07-14
 *          Time: 23:11
 */

//元组
object Test09_Tuple {
  def main(args: Array[String]): Unit = {
    //元组 也可以理解为一个容器 可以存放相同或者不同的数据 简单说 将多个无关的数据封装到一起
    //元组最大元素是22个

    val tuple:(String,Int,Char,Boolean) = ("hello",12,'a',false)
    println(tuple)

    //访问数据 从1开始
    println(tuple._2) //12
    //从索引0开始访问
    println(tuple.productElement(1)) //12

    println("------------")
    //遍历
    for (elem <- tuple.productIterator){
      println(elem)
    }

    println("------------")

    val num = (12,0.2,"hello",(123,"scala"),188)
    println(num._4._2)

  }
}
